package DomainLayer;

import java.util.ArrayList;

public class Customer
{
    private int id;
    private String name;
    private String address;
    private String city;
    private ArrayList<Order> orders;

    public Customer(int id, String name, String address, String city)
    {
        this.id=id;
        this.name=name;
        this.address=address;
        this.city=city;
        orders=new ArrayList<Order>();
    }
    
    public void setName(String name)
    {
        this.name=name;
    }
    
    public String getName()
    {
        return name;
    }
    
    
    public void setAddress(String address)
    {
        this.address=address;
    }
    
    
    public String getAddress()
    {
        return address;
    }
    
    
    public void setCity(String city)
    {
        this.city=city;
    }

    
    public String getCity()
    {
        return city;
    }
    
    
    public void setID(int id)
    {
        this.id=id;
    }
    
    
    public void addOrder(Order order)
    {
        orders.add(order);
    }
    
    //@return money a total amount of money spent in the shop.
    public double getMoneyPaid()
    {
        double money=0;
        for(Order order: orders)
        {
            money+=order.getTotalPrice();
        }
        return money;
    }
    
    public int getID()
    {
        return id;
    }
    
    //@return string an information about the custoemer.
    public String toString()
    {
        String s="Customer's name:" + getName() + '\n' + "Customer's address:" + getAddress() + '\n' + "Customer's city: " + getCity() + '\n';
        s+="Orders: " + '\n';
        for (Order order: orders)
        {
            s+= "Order ID: " + order.getID()+ '\n' + "Made by assistant: " +order.getAssistantName() + '\n' + '\n';
        }
        s+="Money spent at the shop: " +getMoneyPaid();
        
        return s;
    }
}
